<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sj" tagdir="/WEB-INF/tags/spring-jquery-tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<script type="text/javascript">
	$(document).ready(function() {
		$("#editAuditsForm").validate({
			rules : {
				auditsName : {
					required : true
				},
				auditsAcronym : {
					required : true
				}
			}
		});
	});

	$(function() {
		$("#tabs").tabs();
	});

	$('.cancel-button').click(function() {
		loadDiv('content', 'refreshDashboard.do');
	});

	$("#editAuditsForm").validate({
		rules : {
			field : {
				required : true,
				range : [ 0, 100 ]
			}
		}
	});

	function changeColor() {
		var elem = document.getElementById("cipeproject.riskAssessmentScore");
		var val = parseInt(elem.value);
		if (val >= 0 && val <= 20) {
			elem.style.color = "green";
			return;
		}
		if ((val >= 21 && val <= 40)) {
			elem.style.color = "blue";
			return;
		} else {
			elem.style.color = "red";
			return;
		}
	}
</script>
<div id="editAuditsDiv" onload="changeColor()">
	<form:form name="editAuditsForm" id="editAuditsForm" action="saveAudits.do" method="post" modelAttribute="audits">
		<form:hidden path="id" />
		<table>
			<tr class="row">
				<td class="menu-heading" colspan="3"><spring:message code="editAudits.heading" /></td>
			</tr>
			<tr class="row">
				<td class="label">&nbsp;</td>
				<td class="input-field" colspan="2">
					<%@ include file="/common/messages.jsp" %>
				</td>
			</tr>
			<tr class="row">
				<td class="label-small"><spring:message code="editAudits.label.partnerName" /></td>
				<td class="input-field-small"><form:input path="cipeproject.partner.partnerName" cssClass="input-full-width" /></td>
				<td><form:errors path="cipeproject.partner.partnerName" cssClass="error" /></td>
				<td class="label"><spring:message code="editAudits.label.newgrantee" /></td>
				<td class="input-field"><form:checkbox path="newgrantee" cssClass="input-full-width" /></td>
				<td><form:errors path="newgrantee" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label-small"><spring:message code="editAudits.label.donorName" /></td>
				<td class="input-field-small"><form:input path="cipeproject.donoraward.donor.donorName" cssClass="input-full-width" /></td>
				<td><form:errors path="cipeproject.donoraward.donor.donorName" cssClass="error" /></td>
				<td class="label-small"><spring:message code="editAudits.label.donorawardNumber" /></td>
				<td class="input-field-small"><form:input path="cipeproject.donoraward.donorAwardNumber" cssClass="input-full-width" /></td>
				<td><form:errors path="cipeproject.donoraward.donorAwardNumber" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label-small"><spring:message code="editAudits.label.projectTitle" /></td>
				<td class="input-field-small"><form:input path="cipeproject.projectTitle" cssClass="input-full-width" /></td>
				<td><form:errors path="cipeproject.projectTitle" cssClass="error" /></td>
				<td class="label-small"><spring:message code="editAudits.label.projectNumber" /></td>
				<td class="input-field-small"><form:input path="cipeproject.projectID" cssClass="input-full-width" /></td>
				<td><form:errors path="cipeproject.projectID" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label-small"><spring:message code="editAudits.label.projectStartDate" /></td>
				<td class="input-field-small"><form:input path="cipeproject.projectStartDate" cssClass="input-full-width" /></td>
				<%-- <td><form:errors path="cipeproject.projectStartDate" cssClass="error" /></td> --%>
				<td class="label-small"><spring:message code="editAudits.label.projectEndDate" /></td>
				<td class="input-field-small"><form:input path="cipeproject.projectEndDate" cssClass="input-full-width" /></td>
				<%-- <td><form:errors path="cipeproject.projectEndDate" cssClass="error" /></td> --%>
			</tr>
			<tr class="row">
				<td class="label-small"><spring:message code="editAudits.label.grantStartDate" /></td>
				<td class="input-field-small"><form:input path="cipeproject.donoraward.startDate" cssClass="input-full-width" /></td>
				<%-- <td><form:errors path="cipeproject.donoraward.startDate" cssClass="error" /></td> --%>
				<td class="label-small"><spring:message code="editAudits.label.grantEndDate" /></td>
				<td class="input-field-small"><form:input path="cipeproject.donoraward.endDate" cssClass="input-full-width" /></td>
				<%-- <td><form:errors path="cipeproject.donoraward.endDate" cssClass="error" /></td> --%>
			</tr>
		</table>
		<div id="tabs">
			<ul>
				<li><a href="#tabs-1"><spring:message code="editAudits.heading.generalInformation" /></a></li>
				<li><a href="#tabs-2"><spring:message code="editAudits.heading.internalMonitoring" /></a></li>
				<li><a href="#tabs-3"><spring:message code="editAudits.heading.interimAudit" /></a></li>
				<li><a href="#tabs-4"><spring:message code="editAudits.heading.finalAudit" /></a></li>
				<li><a href="#tabs-5"><spring:message code="editAudits.heading.resolution" /></a></li>
				<li><a href="#tabs-6"><spring:message code="editAudits.heading.auditInformation" /></a></li>
			</ul>
			<div id="tabs-1">
				<table>
					<tr class="row">
						<td class="label-small"><spring:message code="editCipeproject.label.region" /></td>
						<td class="input-field-small"><form:input path="cipeproject.region.displayName" cssClass="input-full-width" /></td>
						<td><form:errors path="cipeproject.region.displayName" cssClass="error" /></td>
						<td class="label-small"><spring:message code="editAudits.label.riskAssessmentScore" /></td>
						<td class="input-field-small"><form:input path="cipeproject.riskAssessmentScore" cssClass="input-full-width" onkeyup="changeColor()" /></td>
						<td><span style="color: green">Low = 0-20</span><span style="color: blue"> Medium = 21-40</span><span style="color: red"> High = 41-100</span></td>
						<td><form:errors path="cipeproject.riskAssessmentScore" cssClass="error" /></td>
					</tr>
					<tr class="row">
						<td class="label-small"><spring:message code="editCipeproject.label.country" /></td>
						<td class="input-field-small"><form:input path="cipeproject.country.displayName" cssClass="input-full-width" /></td>
						<td><form:errors path="cipeproject.country" cssClass="error" /></td>
					</tr>
					<tr class="row">
						<td class="label-small"><spring:message code="editCipeproject.label.status" /></td>
						<td class="input-field-small"><form:input path="cipeproject.cipeprojectstatus.displayName" cssClass="input-full-width" /></td>
						<td><form:errors path="cipeproject.cipeprojectstatus.displayName" cssClass="error" /></td>
					</tr>
					<tr>
						<td><spring:message code="editAudits.heading.monitoring" /></td>
					</tr>
					<tr>
						<td class="label-small"><spring:message code="editAudits.label.smponly" /></td>
						<td class="input-field-small"><form:checkbox path="smponly" cssClass="input-full-width" /></td>
						<td><form:errors path="smponly" cssClass="error" /></td>
					</tr>
					<tr>
						<td class="label-small"><spring:message code="editAudits.label.internalMon" /></td>
						<td class="input-field-small"><form:checkbox path="internalmonitoring" cssClass="input-full-width" /></td>
						<td><form:errors path="internalmonitoring" cssClass="error" /></td>
						<td class="label-small"><span style="color: red">Closed to file?</span></td>
					</tr>
					<tr>
						<td class="label-small"><spring:message code="editAudits.label.interimAudit" /></td>
						<td class="input-field-small"><form:checkbox path="interimaudit" cssClass="input-full-width" /></td>
						<td><form:errors path="interimaudit" cssClass="error" /></td>
						<td class="label-small"><spring:message code="label.date" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
					</tr>
					<tr>
						<td class="label-small"><spring:message code="editAudits.label.finalAudit" /></td>
						<td class="input-field-small"><form:checkbox path="finalaudit" cssClass="input-full-width" /></td>
						<td><form:errors path="finalaudit" cssClass="error" /></td>
						<td class="label-small"><spring:message code="label.date" /></td>
						<td class="input-field-small"><form:input path="faclosedtofile" cssClass="input-full-width" /></td>
					</tr>
				</table>
			</div>
			<div id="tabs-2">
				<table>
					<tr>
						<td class="label-small"><spring:message code="editAudits.label.impRequired" /></td>
						<td class="input-field-small"><form:checkbox path="imp" cssClass="input-full-width" /></td>
						<td class="label-small"><spring:message code="editAudits.label.impNotes" /></td>
						<td class="input-field-small"><form:textarea path="impnotes" cssClass="input-full-width" /></td>
					</tr>
				</table>
			</div>
			<div id="tabs-3">
				<table>
					<tr>
						<td class="label-small"><spring:message code="editAudits.label.iaRequired" /></td>
						<td class="input-field-small"><form:checkbox path="interimaudit" cssClass="input-full-width" /></td>
						<td class="label-small"><spring:message code="editAudits.label.auditSolicitor" /></td>
						<td class="input-field-small"><form:select path="" cssClass="input-full-width" /></td>
					</tr>
					<tr>
						<td></td>
						<td class="label-small-left"><spring:message code="editAudits.label.due" /></td>
						<td class="label-small-left"><spring:message code="editAudits.label.received" /></td>
						<td class="label-small-left"><spring:message code="editAudits.label.approved" /></td>
					</tr>
					<tr>
						<td class="label-small"><spring:message code="editAudits.label.interimSelMemo" /></td>
						<td class="input-field-small"><form:input path="interimselectionmemoduedate" cssClass="input-full-width" /></td>
						<td class="input-field-small"><form:input path="interimselectionmemoreceived" cssClass="input-full-width" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
					</tr>
					<tr>
						<td class="label-small"><spring:message code="editAudits.label.interimAuditFirm" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
					</tr>
					<tr>
						<td class="label-small"><spring:message code="editAudits.label.revisedInterimAudit" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
					</tr>
					<tr>
						<td class="label-small"><spring:message code="editAudits.label.resOfFindings" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
					</tr>
					<tr>
						<td class="label-small"><spring:message code="editAudits.label.revisedResOfFindings" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
						<td class="input-field-small"><form:input path="iaclosedtofile" cssClass="input-full-width" /></td>
					</tr>
				</table>
			</div>
			<div id="tabs-4"></div>
			<div id="tabs-5"></div>
			<div id="tabs-6"></div>
		</div>
		<table>
			<tr class="row">
				<td class="label">&nbsp;</td>
				<%-- <td class="input-field" align="center"><button class="cancel-button"><spring:message code="button.cancel" /></button>  --%>
				<sj:submit id="loginFormSubmit" target="editAuditsDiv" key="editAudits.button.save" validate="true" />
				</td>
				<td>&nbsp;</td>
			</tr>
		</table>
	</form:form>
</div>
